package com.itheima.listviewsample;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

public class MyAdapter extends BaseAdapter {
        private List<String> data;
        private Context mContext;

        public MyAdapter(Context mContext, List<String> data) {
            this.mContext = mContext;
            this.data = data;
        }

        @Override
        public int getCount() {
            return data == null ? 0 : data.size();
        }

        @Override
        public Object getItem(int position) {
            return null;
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if (convertView == null) {
                convertView = View.inflate(mContext, R.layout.listview_item, null);
            }

            TextView textView = (TextView) convertView;
            textView.setText(data.get(position));


            return convertView;
        }
    }